import request from '@/utils/request'

// 查询单词测试记录列表
export function listWordTest(query) {
    return request({
        url: '/record/wordTest/list',
        method: 'get',
        params: query
    })
}

export function groupWordTest() {
    return request({
        url: '/record/wordTest/groupData',
        method: 'get'
    })
}

export function groupWordBySchool(school) {
    return request({
        url: '/record/wordTest/groupBySchool/' + school,
        method: 'get'
    })
}

export function statisticsData(data) {
    return request({
        url: '/record/wordTest/statistics/' + data.date + "/" + data.userId,
        method: 'get',
    })
}

export function statisticsDataMore() {
    return request({
        url: '/record/wordTest/statisticsMore',
        method: 'get',
    })
}

export function getUsedTime(number) {
    let timeString = ''
    if (number <= 60) {
        timeString = Math.floor(number) + '秒'
    } else {
        timeString = formatSecondsToChinese(number)
    }
    return timeString
}

//显示“分钟:秒钟”格式
export function formatSecondsToChinese(seconds) {
    const minutes = Math.floor(seconds / 60);
    const secs = Math.floor(seconds % 60);
    return `${minutes}分${secs}秒`;
}

export function listWordTestByUser(query) {
    return request({
        url: '/record/wordTest/list_ByUser',
        method: 'get',
        params: query
    })
}

// 新增单词测试记录
export function addWordTest(data) {
    return request({
        url: '/record/wordTest',
        method: 'post',
        data: data
    })
}

// 新增单词听力记录
export function addWordHear(data) {
    return request({
        url: '/record/wordHear',
        method: 'post',
        data: data
    })
}

// 查询单词听力记录列表
export function listHearRecord(query) {
    return request({
        url: '/record/wordHear/list',
        method: 'get',
        params: query
    })
}

// 查询单词学习记录列表
export function listStudy_record(query) {
    return request({
        url: '/record/study_record/list_ByUser',
        method: 'get',
        params: query
    })
}

// 查询单词学习记录列表
export function write_list_ByUser(query) {
    return request({
        url: '/record/study_record/write_list_ByUser',
        method: 'get',
        params: query
    })
}

// 查询单词学习记录列表
export function list_write_record(query) {
    return request({
        url: '/record/study_record/list_write_all',
        method: 'get',
        params: query
    })
}

export function listStudy_record_ByUser(query) {
    return request({
        url: '/record/study_record/list_ByUser',
        method: 'get',
        params: query
    })
}

// 新增单词学习记录
export function addStudy_record(data) {
    return request({
        url: '/record/study_record',
        method: 'post',
        data: data
    })
}

//年级
export const gradeTypeList = [
    {'type': 'primary', 'label': '初中'},
    {'type': 'middle',  'label': '高中'},
]

//学习记录类型 + 测试
export const studyTypeList = [
    {'type': 'primary', 'label': '初中'},
    {'type': 'middle',  'label': '高中'},
    {'type': 'senior',  'label': '高中872'},
]

//汉英练习类型
export const writeTypeList = [
    {'type': 'write', 'label': '高中'},
    {'type': 'senior_write', 'label': '核心872'},
    {'type': 'primary_write', 'label': '初中'},
]